# -*- coding: UTF-8 -*-
"""
By AnpyD
提升器外观改造
"""

import bs

def pwm(self, text="ice", color=(1, 1, 1), scale=0.01):
    math = bs.newNode("math", owner=self.node, attrs={'input1':(0, 0.5, 0),'operation':'add'})
    self.node.connectAttr("position", math, "input2")
    text = bs.newNode("text", 
                    owner=self.node, 
                     attrs={"text":text, 
                            "color":color, 
                            "inWorld":True, 
                            "scale":scale, 
                            "shadow":0.5, 
                            "flatness":0, 
                            "vAttach":"bottom", 
                            "hAlign":"center"})
    light = bs.newNode("light", 
                        owner=self.node, 
                        attrs={"position":self.node.position, 
                                "color":(color[0]+0.2, color[1]+0.2, color[2]+0.2), 
                                "volumeIntensityScale":1.0, 
                                "intensity":0.6,
                                "radius":1.0})

    math.connectAttr("output", text, "position")
    self.node.connectAttr("position", light, "position")
    bs.animate(light, "radius", {0: 0, 100: 0.4, 6500: 0.2, 7100: 0.0})
    bs.animate(text, 'opacity', {0: 0.0, 1000: 1.0, 5000: 1.0, 7100: 0.0})
    bs.gameTimer(8000, math.delete)
    bs.gameTimer(8000, text.delete)
    bs.gameTimer(8000, light.delete)
